package com.zsh.spring.service;

import com.zsh.spring.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
//import javax.annotation.processing.;

//value 可以省略，默认类名称首字母小写
//@Component(value = "userService")  // value = bean id
@Service
public class UserService {

    @Value(value = "123")
    private String name;

    //定义Dao类型属性,不需要set方法
//    @Autowired  //根据类型注入
//    @Qualifier(value = "userDaoImpl")  //与AutoWired 共同使用

//    @Resource(name = "userService)

    @Autowired
    @Qualifier(value = "userDaoImpl")
    private UserDao userDao;

    public void add(){
        System.out.println("service add");
        userDao.add();
        System.out.println(name);
    }


}
